#pragma once
#include "GSE_CLog.h"
using namespace std;
namespace GSE
{
	class CLogSinkConsole : public ILogSink
	{
	public:
		static CLogSinkConsole * Instance()  { static CLogSinkConsole sink; return &sink; }

		virtual void Write(int c);
		virtual void Flush();
		virtual const char* SinkName()
		{
			return "ConsoleSink";
		}

		virtual void SetSinkParam(const char * ) {}
		virtual void SetSinkParam(const wchar_t * ) {}

	protected:
		virtual void Display(const wstring& str);

		CLogSinkConsole ();
		virtual ~CLogSinkConsole ();
		wstring m_strBuffer;
	};


	class CLogSinkWindow : public CLogSinkConsole
	{
	public:
		static CLogSinkWindow* Instance()  { static CLogSinkWindow sink; return &sink; }
		virtual const char* SinkName()
		{
			return "WindowSink";
		}
	private:
		virtual void Display(const wstring& str);
	};

	class CLogSinkFile : public CLogSinkConsole
	{
	public:
		static CLogSinkFile* Instance()  { static CLogSinkFile sink; return &sink; }

		virtual const char * SinkName()
		{
			return "FileSink";
		}

		void SetFileDir(const char * dir);
		void SetFileHead(const char * head);
		void SetFileTail(const char * tail);

		void SetFileDir(const wchar_t * dir);
		void SetFileHead(const wchar_t * head);
		void SetFileTail(const wchar_t * tail);


		virtual void SetSinkParam(const char * strPathInfo);
		virtual void SetSinkParam(const wchar_t *);

	private:
		virtual void Display(const wstring& str);
		void UpdateLogFile();
		CLogSinkFile();
		virtual ~CLogSinkFile();
		wstring		m_strFileName;          ///< the name of log file
		wstring		m_strFileHead;          ///< the head of file name
		wstring		m_strFileTail;          ///< the tail of file name
		wofstream	m_fsOutput;

		boost::filesystem3::path m_Dir;     ///< the directory of log file
		boost::gregorian::date	m_LastDate; ///< the last time when written log 
	};
}